package library_management.operation.impl;

import library_management.book.Book;
import library_management.book.BookList;
import library_management.operation.IOperation;

public class AddOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("=====================================");
        System.out.println("您当前正在进行添加操作！");
        System.out.println("请输入书籍名称：");
        String newBook=scanner.next();
        if(bookList.isContains(newBook))
        {
            System.out.println("该书已经存在，请勿重复添加！");
            return;
        }
        else
        {
            System.out.println("请输入作者名：");
            String newAuthor=scanner.next();
            System.out.println("请输入书籍的价格：");
            double newPrice=scanner.nextDouble();
            System.out.println("请输入书籍的类型：");
            String newType = scanner.next();
            Book book=new Book(newBook,newAuthor,newPrice,newType);
            bookList.addNewBook(book);
            System.out.println("书籍添加成功！");
        }
    }
}
